﻿using QRCoder;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace PddHelper.Framework
{
    /// <summary>
    /// 二维码生成
    /// </summary>
    public class QrCodeHelper
    {
        /// <summary>
        /// 生成二维码
        /// </summary>
        /// <param name="text"></param>
        public static Bitmap CreateQrCode(string text)
        { 
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData qrCodeData = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
            QRCode qrCode = new QRCode(qrCodeData);

            // 生成二维码图片
            var qrCodeImage = qrCode.GetGraphic(20);

            return qrCodeImage; 
        }
    }
}
